package cn.com.nes.site.entity.em;

import cn.hutool.core.util.ObjectUtil;

import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;

public enum CtceCglyEnum {
    _01("01", "计划内采购", "01"),
    _02( "02", "新增户", "03"),
    _03("03", "遗留户", "04"),
    _04("04", "设备更新", "05"),

    ;

    private String agentCode;

    private String name;

    private String ctceCode;

    CtceCglyEnum(String agentCode, String name, String ctceCode) {
        this.agentCode = agentCode;
        this.name = name;
        this.ctceCode = ctceCode;
    }

    public String getAgentCode() {
        return agentCode;
    }

    public String getName() {
        return name;
    }

    public String getCtceCode() {
        return ctceCode;
    }

    public static CtceCglyEnum getVal(String agentCode) {
        if (ObjectUtil.isNull(agentCode)) {
            return CtceCglyEnum._01; // 如果 aid 为 null，返回默认值
        }
        Map<String, CtceCglyEnum> map = Arrays.stream(values())
                .collect(Collectors.toMap(CtceCglyEnum::getAgentCode, userAidEnum -> userAidEnum));
        return map.getOrDefault(agentCode, CtceCglyEnum._01); // 返回对应的值，如果没有则返回默认值
    }
}